<html lang="en" class="u-bg-transparent turbolinks-progress-bar">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>登录</title>
  <link rel="stylesheet" href="public/css/login.css">
  <link rel="stylesheet" href="request.css" />
  <link rel="stylesheet" href="public/css/doctype.css" />
  <script src="public/js/script.js"></script>
  <script src="public/js/snippet.js"></script>
  <script src="public/js/doctype.js"></script>
  <script src="public/js/jquery.min.js"></script>
  <script src="public/js/Token.js"></script>
  <!-- Vue的配置 -->
  <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js"></script>
</head>
<body>
  <div class="modal signin" role="dialog" aria-labelledby="signin_title">
    <div class="login help_center">
      <div class="interface outer">
        <div id="cancel-link" role="button">
          <a href="#" class="cancel-link" data-close="true" data-close-type="guide" data-no-turbolink="true"
            aria-label="Close dialog" onclick="closedialog()">
            <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" focusable="false"
              viewBox="0 0 16 16">
              <path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M3 13L13 3m0 10L3 3"></path>
            </svg>
          </a>
        </div>
        <div class="clear"></div>
        <h2 class="title" id="signin_title">
          登录至 Huobi
        </h2>
        <div class="interface inner">
          <div class="services external" id="zendesk-js-login-external">
            <a class="service twitter" target="_top" href="">
              <span class="logo"></span><span title="用 Twitter 登录">用 Twitter 登录</span></a>
            <a class="service facebook" id="zd_facebook_login_link" target="_top" href="">
              <span class="logo"></span><span title="用 Facebook 登录">用 Facebook 登录</span></a>
            <a class="service google" target="_top" href="">
              <span class="logo"></span><span title="用谷歌登录">用谷歌登录</span></a></div>

          <div class="separator" id="zendesk-js-login-separator"></div>

          <div class="services internal">
            <!-- <form autocomplete="off" id="login-form" class="" action="" accept-charset="UTF-8" > -->
              <input name="utf8" type="hidden" value="✓">
              <input type="hidden" name="authenticity_token" value="">
              <input type="hidden" name="return_to_on_failure" id="return_to_on_failure" value="">
              <input type="hidden" name="return_to" id="return_to" value="">
              <input type="hidden" name="brand_id" id="brand_id" value="">
              <input type="hidden" name="theme" id="theme">
              <input type="hidden" name="auth_origin" id="auth_origin" value="">
              <input type="hidden" name="form_origin" id="form_origin" value="">
              <div class="credentials">
                <label for="user_email">电邮</label>
                <input autofocus="autofocus" autocomplete="on" type="email" name="Email" id="Email">
                <label for="user_password">密码</label>
                <input autocomplete="off" type="password" name="passWord" id="passWord">
              </div>
              <div class="remember">
                <input type="checkbox" name="remember_me" id="remember_me" value="1">
                <label for="remember_me">保持登录状态</label>
              </div>

              <div class="clear"></div>

              <input type="submit" name="commit"  value="登录" class="button primary" id="login">
            <!-- </form> -->
            <div class="clear"></div>
          </div>

          <div class="clear"></div>

          <div class="assistance">
            <div class="roles" id="zendesk-js-login-roles">
              <a class="multiple_options role agent" href="zendesk.html">我是专员</a>
            </div>
            <div class="forgot_password" id="zendesk-js-forgot-password">
            </div>
          </div>
          <div class="clear"></div>
        </div>
      </div>
      <div class="footnotes">
        <div class="sign_up question">
          <span class="question-text">第一次登录 Huobi?</span>
          <a href="register.html">注册</a>
        </div>
      </div>
    </div>
  </div>
  <script type="text/javascript">

    //判断是否登录成功   
    $("#login").click(function () {
      var Email = document.getElementById("Email"); //全名
      var password = document.getElementById("password"); //密码
      if (Email == "") {
        alert("请输入邮箱!");
        return false;
      } else if (password == "") {
        alert("请输入密码!");
        return false;
      }else{
      var filed = {
        Email: $("input[name='Email']").val(),
        Upwd: $("input[name='passWord']").val(),
      };
      $.ajax({
        type: "Post",
        contentType: "application/json; charset=utf-8",
        url: "http://192.168.137.1:5001/api/values/Login",
        dataType: 'Json',
        data: JSON.stringify(filed),
        // async: true,
        success: function (result) {
          if(result.Success){
            setToken(result.Token);
             parent.location.reload();//父级页面刷新
          }else{
            alert("邮箱或密码错误！");
          }
          datas: result
          
        },
        error: function (result) {
          alert("登录失败");
        }
      });
    }
    });
    
</script>

</body>
</html>